<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Admin\Controller;
use User\Api\UserApi as UserApi;

class ReporterController extends AdminController {
   public function reportlist(){
      $map['status'] = 1;
      $res =$this->lists('report_list',$map);
      $this->assign("_list",$res);
      $this->display();
   }
   public function justify(){
      if(IS_POST){
         $M = M('report_list');
         $M->create();
         $res = $M->save();
         if($res){
            if(I("status")==2){
               M('report_user')->where(array('id'=>I('report_uid')))->setInc('reward',C('REPORTREWARD'));
            }
            $this->success("审核成功",U('reportlist'));
         }else{
            $this->error("审核失败",U('reportlist'));
         }
      }else{
         $map['id'] = I('id');
         $res = M('report_list')->where($map)->find();
         $this->record = $res;
         $this->display();
      }

   }
   public function user(){
      $map['status'] = 1;
      $res = M('report_user') ->where($map)->select();
      $this->assign("_list",$res);
      $this->display();
   }
   public function userinfo(){
      $map['report_uid'] = I('report_uid');
      $res =$this->lists('report_list',$map);
      $this->assign('_list',$res);
      $this->display();
   }
   public function rewardbalance(){
      $map['id'] = I('report_uid');
      if(M('report_user')->where($map)->save(array('reward'=>0))){
         addOrderLog(I('report_uid'),"采价","结算",UID);
         $this->success("结算成功");
      }else{
         $this->error("结算失败");
      }

   }
   public function daily(){
      $map['current_day'] = date("Ymd",time());
      $map['status'] = 2;
      $res = M('Report_list')->where($map)->select();
      $this->assign("_list",$res);
      $this->display();

   }
   public function detail(){
      $map['id'] = I('id');
      $res = M('report_list')->where($map)->find();
      $this->record = $res;
      $this->display();
   }
}
